<?php get_backend_header(array(
	'jquery/validate/jquery.validate.js',
        'jquery/validate/additional-methods.js',
	'exam.js',
), array(
	'jquery/ui.jqgrid.css'
)); ?>

<div id ="content" style ="padding: 14px 0 1px 8px;  background-color: white; float: none; width: auto">
    <h2 class="title">Exam - <?php echo $exam['exam_name'] ?></h2>
    <hr />
    <form id="exam_form" name="exam_form" class="form exam" method="POST" action ="<?php echo site_url('exam/submit') ?>">
        <input type="hidden" id="group_id" name="group_id" value="<?php echo $group['group_id'] ?>" />
        <input type="hidden" id="exam_id" name="exam_id" value="<?php echo $exam['exam_id']; ?>" />
        <input type="hidden" id="mutiples_ids" name="mutiples_ids" value="" />
        <input type="hidden" id="identification_ids" name="identification_ids" value="" />
        <input type="hidden" id="matching_ids" name="matching_ids" value="" />
        <input type="hidden" id="truefalse_ids" name="truefalse_ids" value="" />
        <input type="hidden" id="actual_score_h" name="actual_score_h" value="" />
        <input type="hidden" id="total_score_h" name="total_score_h" value="" />
        <div id ="print_friendly">
            <div class="unit hidden" id="score">
                <div class="line">
                    <label class="bold clear" for="score"><h2>Score: <span id ="actual_score"></span>/<span id ="total_score"></span></h2></label>
                </div>
            </div>

            <div class="clear"></div>

            <?php foreach ($generated_exam as $ge) {
                    echo $ge;
                }
            ?>
            <div class ="clear"></div>
        </div>

        <div class="buttons">
            <a name="cancel" id="cancel" href="<?php echo site_url('exam/list_records/'.$group['group_id']) ?>">Back</a>
            <button id="save" name="save">Submit</button>
            <button class ="hidden" id="print" name="print">Printer Friendly Version</button>
        </div>
    </form>
    
</div>


<script type="text/javascript">

        //initialize checking if instructor has close the exam
        check_answer(false, false);

	$('#cancel').button({
		icons: {primary: 'ui-icon-arrowreturn-1-w'}
	});
	
	$('#print').button().click(function(e){
            e.preventDefault();

            var objData = {
                exam_id: $('#exam_id').val()
            }

            printerFriendly('exam', 'print_take_exam', objData)
        });
	
	$('#save').button({
		icons: {primary: 'ui-icon-arrow'}
	}).click(function(e) {
                e.preventDefault();
		$(this).removeClass('ui-state-focus');
		take_exam_dialog();
	});

</script>

<?php get_backend_footer(); ?>
